<div class="content_filtro">
    <div class="filtro">
        <form id="form_filtro" method="post" action="">
            <i>Filtrar</i>
            <label><?php echo elemform::radio('stfiltro','stfiltro','1',$this->stfiltro); ?> Ativo</label>
            <label><?php echo elemform::radio('stfiltro','stfiltro','0',$this->stfiltro); ?> Inativo</label>
            
            <input type="text" id="filtro_an" name="filtro_an" placeholder="Ano" value="<?php echo $this->filtro_an?>" maxlength="4" style="width: 35px !important;" />
            
            <?php
               
                $query = 'SELECT SQL_CACHE CUR_ID FROM CURSO ORDER BY CUR_ANO DESC';
                $f_cur = $this->db->fetchAll($query);

                $html = '<select id="filtro_tr" name="filtro_tr">';
                $html .= '<option value="">Turma</option>';
                foreach($f_cur as $r){   
                    $select = $this->filtro_tr == $r['CUR_ID'] ? 'selected':''; 
                    $html .= '<option '.$select.' value="'.$r['CUR_ID'].'">'.dominio::getTurma($r['CUR_ID'],0).'</option>'; // $r['CUR_NOM'] 
                }
                $html .= '</select>';
                echo $html;
               
            ?>
           
            <input type="text" name="filtro_nm" placeholder="Aluno" value="<?php echo $this->filtro_nm?>" />
            
            <input type="submit" class="btn-pdr" name="buscar" value="buscar" />
            
        </form>
    </div>
    
    <?php if($this->per_add){?>
    <div class="content-btn">
        <span>Novo</span><a href="<?php echo $this->url(array('controller' => $this->controller, 'action' => 'edit','id'=>'')); ?>">+</a>
    </div>
    <?php } ?>
    
</div>

<div class="content-list">
    
    <h2><?php echo $this->titulo;?></h2>
    
    <table id="tlist">
        <thead>
            <tr>
                <th>Número</th>
                <th>Nome do Aluno</th>
                <th>Data</th>
                <th>Curso</th>
                <th width="80px">Turno</th>
                <th>Turma</th>
                <th width="50px">Semestre</th>
                <th width="50px">Ano</th>
                <th class="bc">&nbsp;</th>
            </tr>
        </thead>
        <tbody>
            <?php foreach ($this->result as $row) { 
                
                $obj2 = new Admin_Model_DbTable_Curso();
                $cur = $obj2->fetchRow('CUR_ID = ' . $row['CUR_ID'])->toArray();
                
                $curso = new Admin_Model_DbTable_Cursobase();
                $curso = $curso->fetchRow('CBS_ID = '.$cur['CBS_ID'])->toArray();
                
                $obj2 = new Admin_Model_DbTable_Aluno();
                $alu = $obj2->fetchRow('ALU_ID = ' . $row['ALU_ID'])->toArray();
            
                $cancelar = true;
                $par = new Admin_Model_DbTable_Parcelamento();
                $pars = $par->fetchAll('MAT_ID = '.$row['MAT_ID'].' and PAR_STAPGO = 0');
                foreach($pars as $par) $cancelar = false;
                
                ?>
                <tr>  
                    <td><?php echo $row['MAT_ID']; ?></td>
                    <td><?php echo $alu['ALU_NOM']; ?></td>
                    <td><?php echo Datetools::invertDH_D($row['MAT_DATHOR']); ?></td>
                    <td><?php echo $curso['CBS_NOM'];//$cur['CUR_NOM']; ?></td>
                    <td><?php echo dominio::getTurno($cur['TUR_ID']); ?></td>
                    <td><?php echo $cur['CUR_TRM']; ?></td>
                    <td><?php echo dominio::getSemestres($cur['CUR_SEM']); ?></td>
                    <td><?php echo $cur['CUR_ANO']; ?></td> 
                    <td class="bc">
                        <?php /* if($this->per_edt){?><a class="btn-bar-list" href="<?php echo $this->url(array('controller' => $this->controller, 'action' => 'boleto', 'id' => $row['CUR_ID'])); ?>" target="_blank">Boleto</a><?php } */ ?>
                        <?php if($this->per_edt){?><a class="btn-pdr" href="<?php echo $this->url(array('controller' => 'parcelamento', 'action' => 'index', 'mat_id' => $row['MAT_ID'])); ?>">Pagamento</a><?php }?>
                        <?php if($this->per_edt){?><a class="btn-pdr" href="<?php echo $this->url(array('controller' => $this->controller, 'action' => 'edit', 'id' => $row['MAT_ID'])); ?>">Editar</a><?php }?>
                        <?php if($this->per_del && $cancelar == true){?><a class="btn-pdr" href="<?php echo $this->url(array('controller' => $this->controller, 'action' => 'delete', 'id' => $row['MAT_ID'])); ?>" >Cancelar</a><?php } ?> 
                    </td>
                </tr>
            <?php } ?>
        </tbody>
    </table>
</div>
<?php echo $this->paginationControl($this->paginator, 'Sliding', 'pagination.phtml'); ?>